www.gusucode.com > VC++ 编写软件自动升级服务源代码 > VC++ 编写软件自动升级服务源代码/gusucode/updater_src0.8.1.6/TransparentStatic.cpp
/******************************************************************** created: 2005/06/25 created: 25:6:2005 11:56 filename: TransparentStatic.cpp file path: Updater file base: TransparentStatic file ext: cpp author: purpose: *********************************************************************/ //********************************************************************* // INCLUDES //********************************************************************* #include "stdafx.h" #include "TransparentStatic.h" IMPLEMENT_DYNAMIC(CTransparentStatic, CStatic) //********************************************************************* // MESSAGE MAP //********************************************************************* BEGIN_MESSAGE_MAP(CTransparentStatic, CStatic) ON_WM_PAINT() END_MESSAGE_MAP() //********************************************************************* // CONSTRUCTOR & DESTRUCTOR //********************************************************************* CTransparentStatic::CTransparentStatic() { } //===================================================================== CTransparentStatic::~CTransparentStatic() { } //********************************************************************* // PUBLIC FUNCTIONS //********************************************************************* void CTransparentStatic::OnPaint() { CPaintDC dc(this); // device context for painting // Where to draw text CRect client_rect; GetClientRect(client_rect); // Get the caption CString szText; GetWindowText(szText); // Get the font CFont *pFont, *pOldFont; pFont = GetFont(); pOldFont = dc.SelectObject(pFont); // Map "Static Styles" to "Text Styles" #define MAP_STYLE(src, dest) if(dwStyle & (src)) dwText |= (dest) #define NMAP_STYLE(src, dest) if(!(dwStyle & (src))) dwText |= (dest) DWORD dwStyle = GetStyle(), dwText = 0; MAP_STYLE( SS_RIGHT, DT_RIGHT ); MAP_STYLE( SS_CENTER, DT_CENTER ); MAP_STYLE( SS_CENTERIMAGE, DT_VCENTER | DT_SINGLELINE ); MAP_STYLE( SS_NOPREFIX, DT_NOPREFIX ); MAP_STYLE( SS_WORDELLIPSIS, DT_WORD_ELLIPSIS ); MAP_STYLE( SS_ENDELLIPSIS, DT_END_ELLIPSIS ); MAP_STYLE( SS_PATHELLIPSIS, DT_PATH_ELLIPSIS ); NMAP_STYLE( SS_LEFTNOWORDWRAP | SS_CENTERIMAGE | SS_WORDELLIPSIS | SS_ENDELLIPSIS | SS_PATHELLIPSIS, DT_WORDBREAK ); // Set transparent background dc.SetBkMode(TRANSPARENT); // Draw the text dc.DrawText(szText, client_rect, dwText); // Select old font dc.SelectObject(pOldFont); } //********************************************************************* // PRIVATE FUNCTIONS //*********************************************************************